const app = getApp();
var _openid = app.getOpenId();

Page({
  data: {
    carNumber: 0,    //车牌号
    nickName: "",    //车主的昵称
    telNum: "",      //车主电话号码
    areaName: "",    //小区大厦名称
    parkingNumber: "", //车位编号
    createTime: "", //开始的时间
    endTime: "",    //结束的时间
    longitude: "",  //发布车位的精度
    latitude: "",  //发布车位的纬度
    rentPrice: "", //出租价格
  },
  onLoad() {

  },


  nickNameInput: function (e) {
    console.log('业主昵称' + e.detail.value);
    this.setData({
      nickName: e.detail.value
    })
  },

  telInput: function (e) {
    console.log('业主电话' + e.detail.value);
    this.setData({
      telNum: e.detail.value
    })
  },

  areaNameInput: function (e) {
    console.log('小区/大厦' + e.detail.value);
    this.setData({
      areaName: e.detail.value
    })
  },

  parkingNumInput: function (e) {
    console.log('车位号' + e.detail.value);
    this.setData({
      parkingNumber: e.detail.value
    })
  },


  createTimeInput: function (e) {
    console.log('起租时间:' + e.detail.value);
    this.setData({
      createTime: e.detail.value
    })
  },

  endTimeInput: function (e) {
    console.log('停租时间:' + e.detail.value);
    this.setData({
      endTime: e.detail.value
    })
  },

  rentPriceInput: function (e) {
    console.log('出租价格:' + e.detail.value);
    this.setData({
      rentPrice: e.detail.value
    })
  },

  rentRemarkInput: function (e) {
    console.log(e.detail.value);
    this.setData({
      rentRemark: e.detail.value
    })
  },


  onShow() {
    this.setData({
      version: app.globalData.version
    });
  },

  aboutUs: function () {
    console.log(this.data.nickName, this.data.telNum, this.data.areaName, this.data.parkingNumber, this.data.createTime, this.data.endTime, this.data.longitude, this.data.latitude);

    var that = this;
    wx.request({
      url: app.globalData.domain + app.globalData.subDomain +'/parking/pubParking?',
      method: 'post',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        openid: _openid,
        areaName: this.data.nickName,
        parkingNumber: this.data.parkingNumber,
        startTime: this.data.startTime,
        endTime: this.data.endTime,
        rentPrice: this.data.rentPrice,
        longitude: this.data.longitude,
        latitude: this.data.latitude,
        rentRemark: this.data.rentRemark
      },
      success: function (res) {
        if (res.data.code == 0) {
          that.setData({
            noticeList: res.data.data
          });
        }
      }
    })
  }
})